<div class="eui-layout" data-options="fit:true">
	<div data-options="region:'west',split:true, border:false" style="width:470px;">
		<table id="tree1" title="字典类型" class="eui-treegrid"
			data-options="
				fit:true, 
				animate: true,
				singleSelect:false,
				fitColumns: true,scrollbarSize :0,
				url: '${path}/eframe/dict/type/type!list.action',
				method: 'post',
				idField: 'id',
				treeField: 'name',
				pagination: true,
				onClickRow: requestDictInfo,
				pageList:[10,15,20,30,50,100],
				pageSize:10,
				toolbar:'#tools1'">
			<thead>
				<tr>
					<th data-options="field:'id',checkbox:true"></th>
					<th data-options="field:'name',width:50,halign:'center',align:'left'">类型名称</th>
					<th data-options="field:'code',width:50,halign:'center',align:'left'">类型编码</th>
				</tr>
			</thead>
		</table>
		<div id="tools1" style="padding:5px;height:auto">
			<div style="margin-bottom:5px">
				<a href="javascript:void(0)" class="eui-linkbutton" iconCls="icon-add" plain="true" id="addbtn1">添加</a>
				<a href="javascript:void(0)" class="eui-linkbutton" iconCls="icon-add" plain="true" id="addsubbtn1">添加子项</a>
				<a href="javascript:void(0)" class="eui-linkbutton" iconCls="icon-edit" plain="true" id="updatebtn1">修改</a>
				<a href="javascript:void(0)" class="eui-linkbutton" iconCls="icon-remove" plain="true" id="deletebtn1">删除</a>
				<a href="javascript:void(0)" class="eui-linkbutton" iconCls="icon-search" plain="true" id="searchbtn1">查询</a>
			</div>
			<div>
				<table class="condition-table">
					<tr>
						<th>类型名称：</th>
						<td><input class="eui-textbox" style="width:120px" name="criteria.expr['typename_like']"></td>
						<th>类型编码：</th>
						<td><input class="eui-textbox" style="width:120px" name="criteria.expr['typecode_like']"></td>
					</tr>
				</table>
			</div>
		</div>
	</div>
	<div data-options="region:'center', border:false">
		<table id="tree2" title="字典信息" class="eui-treegrid"
			data-options="
				collapsible:false,
				fit:true,
				animate: true,
				singleSelect:false,
				fitColumns: true,scrollbarSize :0,
				url: '${path}/eframe/dict/info/info!list.action',
				method: 'post',
				idField: 'id',
				treeField: 'name',
				onClickRow: onlySelectTreegridRow,
				pagination: true,
				pageList:[10,15,20,30,50,100],
				pageSize:10,
				toolbar:'#tools2'">
			<thead>
				<tr>
					<th data-options="field:'id',checkbox:true"></th>
					<th data-options="field:'name',width:40,halign:'center',align:'left'">字典名称</th>
					<th data-options="field:'code',width:40,halign:'center',align:'left'">字典编码</th>
					<th data-options="field:'sortno',width:20,halign:'center',align:'center'">字典顺序</th>
				</tr>
			</thead>
		</table>
		<div id="tools2" style="padding:5px;height:auto">
			<div style="margin-bottom:5px;">
				<a href="javascript:void(0)" class="eui-linkbutton" iconCls="icon-add" plain="true" id="addbtn2">添加</a>
				<a href="javascript:void(0)" class="eui-linkbutton" iconCls="icon-add" plain="true" id="addsubbtn2">添加子项</a>
				<a href="javascript:void(0)" class="eui-linkbutton" iconCls="icon-edit" plain="true" id="updatebtn2">修改</a>
				<a href="javascript:void(0)" class="eui-linkbutton" iconCls="icon-remove" plain="true" id="deletebtn2">删除</a>
				<a href="javascript:void(0)" class="eui-linkbutton" iconCls="icon-search" plain="true" id="searchbtn2">查询</a>
			</div>
			<div>
				<input class="textbox-value" name="typeId" id="typeId"/>
				<input class="textbox-value" name="criteria.order['sortno_0']" value="asc"/>
				<input class="textbox-value" name="criteria.order['createTime_1']" value="desc"/>
				<table class="condition-table">
					<tr>
						<th>字典名称：</th>
						<td><input class="eui-textbox" style="width:120px" id="infoname" name="criteria.expr['infoname_like']"></td>
						<th>字典编码：</th>
						<td><input class="eui-textbox" style="width:120px" id="infocode" name="criteria.expr['infocode_like']"></td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>
<script>
	
	function requestDictInfo(row) {
		$("#tree1").treegrid('onlySelectThisRow', row);
		$("#typeId").val(row.id);
		$("#infoname").textbox('clear');
		$("#infocode").textbox('clear');
		$("#tree2").treegrid('reloadWithCriteria');
	}
	
	$("#addbtn1").click(function() {
		dialog.open({
			width:650,
			height:350,
			url:'${path}/eframe/dict/type/type!addView.action',
			success:function(text){
				$("#tree1").treegrid('reloadWithCriteria');
			}
		});
	});
	$("#addsubbtn1").click(function() {
		var nodes = $("#tree1").treegrid('getSelections');
		if(nodes.length != 1) {
			$.messager.alert('提示','请选中一个字典类型作为上级字典类型','warning');
		} else {
			dialog.open({
				width:650,
				height:350,
				url:'${path}/eframe/dict/type/type!addView.action?id='+(nodes[0]?nodes[0].id:''),
				success:function(text){
					$("#tree1").treegrid('reloadSelected');
				}
			});
		}
	});
	$("#updatebtn1").click(function(){
		var nodes = $("#tree1").treegrid('getSelections');
		if(nodes.length != 1) {
			$.messager.alert('提示','请选中一个字典类型','warning');
		} else {
			dialog.open({
				width:650,
				height:350,
				url:'${path}/eframe/dict/type/type!updateView.action?id='+(nodes[0]?nodes[0].id:''),
				success:function(text){
					$("#tree1").treegrid('reloadParent');
				}
			});
		}
	});
	$("#deletebtn1").click(function(){
		$("#tree1").treegrid("deleteSelected",{
			url: "${path}/eframe/dict/type/type!delete.action"
		});
	});
	
	$("#searchbtn1").click(function(){
		$("#tree1").treegrid('reloadWithCriteria');
	});
	
	
	//字典信息部分
	$("#addbtn2").click(function(){
		var types = $("#tree1").treegrid('getSelections');
		if(types.length != 1) {
			$.messager.alert('提示','请选中一个字典类型','warning');
		} else {
			dialog.open({
				width:650,
				height:350,
				url:'${path}/eframe/dict/info/info!addView.action?typeId='+types[0].id,
				success:function(text){
					$("#tree2").treegrid('reloadWithCriteria');
				}
			});
		}
	});
	$("#addsubbtn2").click(function(){
		var infos = $("#tree2").treegrid('getSelections');
		if(infos.length != 1) {
			$.messager.alert('提示','请选中一个字典信息作为上级字典信息','warning');
		} else {
			dialog.open({
				width:650,
				height:350,
				url:'${path}/eframe/dict/info/info!addView.action?id='+(infos[0]?infos[0].id:''),
				success:function(text){
					$("#tree2").treegrid('reloadSelected');
				}
			});
		}
	});
	$("#updatebtn2").click(function(){
		var infos = $("#tree2").treegrid('getSelections');
		if(infos.length != 1) {
			$.messager.alert('提示','请选中一个字典信息','warning');
		} else {
			dialog.open({
				width:650,
				height:350,
				url:'${path}/eframe/dict/info/info!updateView.action?id='+(infos[0]?infos[0].id:''),
				success:function(text){
					$("#tree2").treegrid('reloadParent');
				}
			});
		}
	});
	$("#deletebtn2").click(function(){
		$("#tree2").treegrid("deleteSelected",{
			url: "${path}/eframe/dict/info/info!delete.action"
		});
	});
	$("#searchbtn2").click(function(){
		var types = $("#tree1").treegrid('getSelections');
		if(types.length == 0) {
			$("#typeId").val('');
		}
		$("#tree2").treegrid('reloadWithCriteria');
	});
</script>